package cn.rongdao.jrkabao.ui.cashadvance.uicomponent;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mifengkong.frtools.util.FRString;

import cn.rongdao.jrkabao.R;

/**
 * Created by jack on 2017/9/13
 */

public class PaymentDateUIComponent extends RelativeLayout {

    public PaymentDateUIComponent(Context context) {
        super(context);
    }

    public PaymentDateUIComponent(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public PaymentDateUIComponent(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    private TextView tvTime;
    private TextView tvSuccessTip;
    private TextView tvFailureTip;
    private TextView tvName;

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        tvTime = (TextView) findViewById(R.id.lpd_tv_time);
        tvSuccessTip = (TextView) findViewById(R.id.lpd_tv_success_tip);
        tvFailureTip = (TextView) findViewById(R.id.lpd_tv_failure_tip);
        tvName = (TextView) findViewById(R.id.lpd_tv_name);
    }

    public void setContent(String name, String time, String tip) {
        setVisibility(View.VISIBLE);
        tvName.setText(FRString.valueOf(name));
        if (!FRString.isEmpty(time)) {
            tvSuccessTip.setText(FRString.valueOf(tip));
            tvTime.setText(FRString.valueOf(time));
            tvSuccessTip.setVisibility(View.VISIBLE);
        } else {
            tvFailureTip.setText(FRString.valueOf(tip));
            tvTime.setVisibility(View.GONE);
            tvFailureTip.setVisibility(View.VISIBLE);
        }
    }
}